package weaver.conn;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.Statement;
import weaver.conn.StatementInterceptor;
import weaver.conn.WeaverConnection;
import weaver.general.BaseBean;

public class WeaverStatement implements Statement {
    private final Statement statement;

    private final WeaverConnection connection;

    public WeaverStatement(WeaverConnection paramWeaverConnection, Statement paramStatement) {
        this.connection = paramWeaverConnection;
        this.statement = paramStatement;
    }

    public ResultSet originExecuteQuery(String paramString) throws SQLException {
        beforeExecute(paramString);
        ResultSet resultSet = this.statement.executeQuery(paramString);
        finishedExecute(paramString);
        return resultSet;
    }

    public int originExecuteUpdate(String paramString) throws SQLException {
        beforeExecute(paramString);
        int i = this.statement.executeUpdate(paramString);
        finishedExecute(paramString);
        return i;
    }

    public void closeNoException() {
        try {
            this.statement.close();
        } catch (SQLException sQLException) {
            (new BaseBean()).writeLog(sQLException);
        }
    }

    public ResultSet executeQuery(String paramString) throws SQLException {
        paramString = intercepting(paramString);
        beforeExecute(paramString);
        ResultSet resultSet = this.statement.executeQuery(paramString);
        finishedExecute(paramString);
        return resultSet;
    }

    public int executeUpdate(String paramString) throws SQLException {
        paramString = intercepting(paramString);
        beforeExecute(paramString);
        int i = this.statement.executeUpdate(paramString);
        finishedExecute(paramString);
        return i;
    }

    public void close() throws SQLException {
        this.statement.close();
    }

    public int getMaxFieldSize() throws SQLException {
        return this.statement.getMaxFieldSize();
    }

    public void setMaxFieldSize(int paramInt) throws SQLException {
        this.statement.setMaxFieldSize(paramInt);
    }

    public int getMaxRows() throws SQLException {
        return this.statement.getMaxRows();
    }

    public void setMaxRows(int paramInt) throws SQLException {
        this.statement.setMaxRows(paramInt);
    }

    public void setEscapeProcessing(boolean paramBoolean) throws SQLException {
        this.statement.setEscapeProcessing(paramBoolean);
    }

    public int getQueryTimeout() throws SQLException {
        return this.statement.getQueryTimeout();
    }

    public void setQueryTimeout(int paramInt) throws SQLException {
        this.statement.setQueryTimeout(paramInt);
    }

    public void cancel() throws SQLException {
        this.statement.cancel();
    }

    public SQLWarning getWarnings() throws SQLException {
        return this.statement.getWarnings();
    }

    public void clearWarnings() throws SQLException {
        this.statement.clearWarnings();
    }

    public void setCursorName(String paramString) throws SQLException {
        this.statement.setCursorName(paramString);
    }

    public boolean execute(String paramString) throws SQLException {
        paramString = intercepting(paramString);
        beforeExecute(paramString);
        boolean bool = this.statement.execute(paramString);
        finishedExecute(paramString);
        return bool;
    }

    public ResultSet getResultSet() throws SQLException {
        return this.statement.getResultSet();
    }

    public int getUpdateCount() throws SQLException {
        return this.statement.getUpdateCount();
    }

    public boolean getMoreResults() throws SQLException {
        return this.statement.getMoreResults();
    }

    public void setFetchDirection(int paramInt) throws SQLException {
        this.statement.setFetchDirection(paramInt);
    }

    public int getFetchDirection() throws SQLException {
        return this.statement.getFetchDirection();
    }

    public void setFetchSize(int paramInt) throws SQLException {
        this.statement.setFetchSize(paramInt);
    }

    public int getFetchSize() throws SQLException {
        return this.statement.getFetchSize();
    }

    public int getResultSetConcurrency() throws SQLException {
        return this.statement.getResultSetConcurrency();
    }

    public int getResultSetType() throws SQLException {
        return this.statement.getResultSetType();
    }

    public void addBatch(String paramString) throws SQLException {
        paramString = intercepting(paramString);
        this.statement.addBatch(paramString);
    }

    public void clearBatch() throws SQLException {
        this.statement.clearBatch();
    }

    public int[] executeBatch() throws SQLException {
        return this.statement.executeBatch();
    }

    public Connection getConnection() throws SQLException {
        return this.statement.getConnection();
    }

    public boolean getMoreResults(int paramInt) throws SQLException {
        return this.statement.getMoreResults(paramInt);
    }

    public ResultSet getGeneratedKeys() throws SQLException {
        return this.statement.getGeneratedKeys();
    }

    public int executeUpdate(String paramString, int paramInt) throws SQLException {
        paramString = intercepting(paramString);
        beforeExecute(paramString);
        int i = this.statement.executeUpdate(paramString, paramInt);
        finishedExecute(paramString);
        return i;
    }

    public int executeUpdate(String paramString, int[] paramArrayOfint) throws SQLException {
        paramString = intercepting(paramString);
        beforeExecute(paramString);
        int i = this.statement.executeUpdate(paramString, paramArrayOfint);
        finishedExecute(paramString);
        return i;
    }

    public int executeUpdate(String paramString, String[] paramArrayOfString) throws SQLException {
        paramString = intercepting(paramString);
        beforeExecute(paramString);
        int i = this.statement.executeUpdate(paramString, paramArrayOfString);
        finishedExecute(paramString);
        return i;
    }

    public boolean execute(String paramString, int paramInt) throws SQLException {
        paramString = intercepting(paramString);
        beforeExecute(paramString);
        boolean bool = this.statement.execute(paramString, paramInt);
        finishedExecute(paramString);
        return bool;
    }

    public boolean execute(String paramString, int[] paramArrayOfint) throws SQLException {
        paramString = intercepting(paramString);
        beforeExecute(paramString);
        boolean bool = this.statement.execute(paramString, paramArrayOfint);
        finishedExecute(paramString);
        return bool;
    }

    public boolean execute(String paramString, String[] paramArrayOfString) throws SQLException {
        paramString = intercepting(paramString);
        beforeExecute(paramString);
        boolean bool = this.statement.execute(paramString, paramArrayOfString);
        finishedExecute(paramString);
        return bool;
    }

    public int getResultSetHoldability() throws SQLException {
        return this.statement.getResultSetHoldability();
    }

    public boolean isClosed() throws SQLException {
        return this.statement.isClosed();
    }

    public void setPoolable(boolean paramBoolean) throws SQLException {
        this.statement.setPoolable(paramBoolean);
    }

    public boolean isPoolable() throws SQLException {
        return this.statement.isPoolable();
    }

    public void closeOnCompletion() throws SQLException {
        this.statement.closeOnCompletion();
    }

    public boolean isCloseOnCompletion() throws SQLException {
        return this.statement.isCloseOnCompletion();
    }

    public <T> T unwrap(Class<T> paramClass) throws SQLException {
        return this.statement.unwrap(paramClass);
    }

    public boolean isWrapperFor(Class<?> paramClass) throws SQLException {
        return this.statement.isWrapperFor(paramClass);
    }

    private boolean needIntercept(String paramString) {
        return StatementInterceptor.needIntercept(paramString);
    }

    private String intercepting(String paramString) {
        return StatementInterceptor.intercepting(paramString);
    }

    private void beforeExecute(String paramString) {}

    private void finishedExecute(String paramString) {}
}
